package com.cdck.safe.dete.common.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Set;


/**
 * @author : Sakura
 * @Date : 2023/11/23 9:27
 * @Description : TODO 清空缓存数据库，排队只留下当天的排队信息
 */
@Component
public class ScheduleBean {

    @Autowired
    private StringRedisTemplate redisTemplate;

    /**
     * 清空缓存数据库，排队只留下当天的排队信息
     * @param :
     * @return void
     * @author Sakura
     * @date 2023/11/23 9:31
     */
    @Scheduled(cron = "0 0 0 * * *")
    public void checkProjectTask() {

        System.out.println("每天0点执行一次，清空redis");
        Set<String> keys = redisTemplate.keys("*");
        redisTemplate.delete(keys);
    }
}
